import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
import { GetSeatInfoParams, EditSeatParams, SeatInfo } from 'admin/schema/Seat';
/* 坐席管理
---------------------------------------------------------------- */

/**新增坐席 */
export const addSeat = (data: EditSeatParams): Promise<Result<null>> => {
  return $http.post({
    url: '/sso/seat',
    data,
  });
};

/** 删除坐席 */
export const delSeat = (SeatsId: number): Promise<Result<null>> => {
  return $http.delete({
    url: `/sso/seat/${SeatsId}`,
  });
};

/**编辑坐席 */
export const modifySeat = (id: number, data: EditSeatParams): Promise<Result<null>> => {
  return $http.put({
    url: `/sso/seat/${id}`,
    data,
  });
};

/**获取坐席列表 */
export const getSeatList = (data: GetSeatInfoParams): Promise<Result<SeatInfo[]>> => {
  return $http.get({
    url: '/sso/seat',
    data,
  });
};

/**获取单个用户详细信息 */
export const getSeatInfo = (SeatsId: number): Promise<Result<SeatInfo>> => {
  return $http.get({
    url: `/sso/seat/${SeatsId}`,
  });
};

/**重置密码 */
export const resetSeatPwd = (data: {
  userName: string;
  passWord: string;
  userId: number;
}): Promise<Result<null>> => {
  return $http.patch({
    url: '/sso/seat/password/reset',
    data,
  });
};

/**停用/启用坐席 */
export const enableSeatUser = (
  userId: number,
  data: { userStatus: 0 | 1 }
): Promise<Result<null>> => {
  return $http.patch({
    url: `/sso/seat/${userId}`,
    data,
  });
};
